package main

import (
	"flag"
	"fmt"
	"serverlog/global"
	"serverlog/src"
	"time"
)

var (
	h        bool
	confPath string
)

func init() {
	flag.BoolVar(&h, "h", false, "帮助")
	flag.StringVar(&confPath, "c", ".", "配置文件目录")

	flag.Usage = usage
}

func usage() {
	fmt.Println("Usage: server [-h] [-c] conf_dir\nOptions:\n")
	flag.PrintDefaults()
}

func main() {
	flag.Parse()
	if h {
		flag.Usage()
	}
	global.ClientGlobal.Init(confPath)
	c := serverlog.NewClient("client test", global.ClientGlobal.Addr, global.ClientGlobal.Port)

	num := 0
	for {
		switch num % 3 {
		case 0:
			c.Errorf("error send %d", num)
		case 1:
			c.Infof("info send %d", num)
		case 2:
			c.Debugf("debug send %d", num)
		}
		num++
		time.Sleep(time.Millisecond * 5)
	}
}
